<div class='form-group'>
    {{#if title}}
        <label for="{{tagId}}">
            {{title}}
        </label>
    {{/if}}
   
	<fieldset id="{{tagId}}">
	{{#if togglable}}
		{{#if editable}}
		<div class="layout flex editable">
		{{else}}
		<div>
		{{/if}}
	{{/if}}
			<div class="content {{#if layout}}layout flex {{layout}}{{/if}}">
    
			{{#if editing}}
				{{#unless options}}
				  <em>{{noOptionMessage}}</em>
				{{/unless }}
				{{#each options}}
				<div>
					<div class="checkbox">
						<label>
							<input 
								id="{{tagId}}" 
								type='checkbox'
								multiple="multiple"
								name='{{ ../field_name }}'
								value='{{this.id}}'
								aria-label="{{this.label}}"
								{{#if this.selected}}checked{{/if}} />
							<span>{{this.label}}</span>
						</label>
					</div>
					{{#if ../description}}
					<span class='help-block'>{{ ../description }}</span>
					{{/if}}
					{{#if this.help_text}}
					<span class='help-block'>{{ this.help_text }}</span>
					{{/if}}
				</div>
				{{/each }}
			{{else}}
                {{# if selectedOptions.length }}
				    <ul>
					    {{#each selectedOptions}}
					        <li>{{this.label}}</li>
					    {{/each }}
				    </ul>
                {{else}}
				    <em>{{noOptionMessage}}</em>
                {{/if}}
			{{/if}}
			</div>

	{{#if togglable}}
		{{#if editable}}
			{{#if editing }}
			<button class='btn icon only unstyled edit' title='Replier la liste' aria-label='Replier la liste'>
				<svg><use href="/static/icons/endi.svg#chevron-up"></use></svg>
			</button>
			{{else}}
              {{# if selectedOptions.length }}
			      <button class='btn icon only edit' title='Modifier' aria-label='Modifier'>
				      <svg><use href="/static/icons/endi.svg#pen"></use></svg>
			      </button>
              {{else}}
			      <button class='btn icon only edit' title='Rattacher une commande' aria-label='Rattacher une commande'>
				      <svg><use href="/static/icons/endi.svg#link"></use></svg>
			      </button>

              {{/if}}
			{{/if}}
		{{/if}}
	{{/if}}

    </fieldset>
</div>
